package week_1;
//[5,2,6,4,1]
//        [[3,1,2],[4,10,3],[3,10,100],[4,100,30],[1,3,1]]
import toolPackage.tool;

import java.util.Arrays;

public class day02_week01 {
    public static void main(String[] args) {
//        int[] candiesCount=tool.random0To10(tool.random0To100());
//        int[][] queries=new int[tool.random0To10()][3];
//        for (int i=0;i<queries.length;i++){
////            int[] ints=tool.random0To10(3);
////            System.out.println(Arrays.toString(ints));
////            queries[i]=ints;
//            queries[i]=tool.random0To10(3);
//        }
        //System.out.println(Arrays.toString(queries));

        int[] candiesCount=new int[]{46,5,47,48,43,34,15,26,11,25,41,47,15,25,16,50,32,42,32,21,36,34,50,45,46,15,46,38,50,12,3,26,26,16,23,1,4,48,47,32,47,16,
                33,23,38,2,19,50,6,19,29,3,27,12,6,22,33,28,7,10,12,8,13,24,21,38,43,26,35,18,34,3,14,48,50,34,38,4,50,26,5,35,11,2,35,9,11,31,36,20,21,37,18,34,
                34,10,21,8,5};
        int[][] queries=new int[][]{{85,54,42}};
        boolean[] answer = canEat(candiesCount,queries);
        System.out.println(Arrays.toString(answer));
    }


    public static boolean[] canEat(int[] candiesCount, int[][] queries) {
        boolean[] answer=new boolean[queries.length];
        //创建一个糖果的解析数组
        int[] sweet=new int[candiesCount.length+1];
        sweet[0]=0;
        for (int i=1;i<sweet.length;i++){
            sweet[i]=sweet[i-1]+candiesCount[i-1];
        }

        for(int i=0;i<answer.length;i++){
            //如果每天只吃一颗糖,食用糖数量能否在i类糖范围内

            System.out.println(queries[i][1] * 1);//a
            System.out.println(sweet[queries[i][0] +1] - 1);//d
            System.out.println(sweet[queries[i][0]]);//c0
            System.out.println(queries[i][1]*queries[i][2]);//b
//            if(queries[i][1]*1<=sweet[queries[i][0]]-1&&queries[i][1]*1>=sweet[queries[i][0]-1]) {
//                answer[i] = true;
//            }
//            //如果每天吃最多的糖,食用糖数量能否在i类糖范围内
//            else if (queries[i][1]*queries[i][2]<=sweet[queries[i][0]]-1&&queries[i][1]*queries[i][2]>=sweet[queries[i][0]-1]){
//                answer[i]=true;
//            }
//            else
//                answer[i]=false;


            if (queries[i][1] * 1>=sweet[queries[i][0]]){
                if(queries[i][1] * 1<=sweet[queries[i][0] + 1] - 1){
                    answer[i]=true;
                }
            }else if (queries[i][1]*queries[i][2]>=sweet[queries[i][0]]){
                answer[i]=true;
            }else {
                answer[i]=false;
            }
        }
        return answer;
    }
}
